﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1 {
    /// <summary>
    /// Lógica de interacción para MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window {

        private SawDataContext ctx= new SawDataContext();

        public MainWindow() {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e) {
         //   App.Current.Properties["ctx"] = ctx;

            cmbCustomers.ItemsSource = (from c in ctx.Cliente
                                       select
                                       new Tuple<string, string>(c.Codigo,c.Nombre)).Take(100);
            
            cmbCustomers.DisplayMemberPath = "Item2";

        }

        private void cmbCustomers_SelectionChanged(object sender, SelectionChangedEventArgs e) {
            var cliente = (Tuple<string, string>)cmbCustomers.SelectedValue;

            lstOrders.ItemsSource = from c in ctx.CxC
                                    where c.CodigoCliente == cliente.Item1
                                    select new {
                                        c.Numero, c.CodigoMoneda, c.MontoGravado

                                    };



        }

        private void mnuSave_Click(object sender, RoutedEventArgs e) {

        }

        private void mnuOrder_Click(object sender, RoutedEventArgs e) {

        }

        private void mnuExit_Click(object sender, RoutedEventArgs e) {
            App.Current.Shutdown();
        }
    }
}
